<template>
  <el-select v-model="innerValue" style="width:150px">
    <el-option
        v-for="item in options"
        :key="item.value"
        :label="item.productName"
        :value="item.productKey"
    />
  </el-select>
</template>

<script setup name="ProductKeySelect">
import { listProductKey } from '@/api/manager/productInfo'
const options = ref([]);

const props= defineProps({
  modelValue: {
    type: String,
  },
})

const emit = defineEmits(['update:modelValue']);
const innerValue = ref(props.modelValue);

onMounted(() => {
  listProductKey().then(res => {
    options.value = res.data
  })
})

watch(() => innerValue.value, value => {
  emit('update:modelValue', value);
})

watch(() => props.modelValue, value => {
  innerValue.value = value
})
</script>